import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class JFrameProfesor extends javax.swing.JFrame {

	private Seccion sec = new Seccion();
	private JPanel jPanelProf;
	private JTextField txtApeProf;
	private JLabel lblApellProf;
	private JTextField txtCedProf;
	private JLabel lblCedProf;
	private JLabel lblNomProf;
	private JLabel lblNroSeccion;
	private JButton btAsigProf;
	private JTextField txtTAcProf;
	private JLabel lblTAcProf;
	private JTextField txtNomProf;
	private JLabel lblDatProf;
	private JLabel lblSecProf;
	private JLabel jLabel1;
	private JLabel lblSeccProf;
	private Seccion s = new Seccion();
	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrameProfesor inst = new JFrameProfesor();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public JFrameProfesor() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Administrador de Profesores");
			{
				jPanelProf = new JPanel();
				GroupLayout jPanelProfLayout = new GroupLayout((JComponent)jPanelProf);
				jPanelProf.setLayout(jPanelProfLayout);
				getContentPane().add(jPanelProf, BorderLayout.CENTER);
				jPanelProf.setPreferredSize(new java.awt.Dimension(501, 270));
				jPanelProf.setBackground(new java.awt.Color(255,255,255));
				{
					lblSecProf = new JLabel();
					GroupLayout lblSecProfLayout = new GroupLayout((JComponent)lblSecProf);
					lblSecProf.setLayout(lblSecProfLayout);
					lblSecProf.setText("Nro de Seccion:");
					lblSecProfLayout.setVerticalGroup(lblSecProfLayout.createSequentialGroup());
					lblSecProfLayout.setHorizontalGroup(lblSecProfLayout.createSequentialGroup());
				}
				{
					lblDatProf = new JLabel();
					lblDatProf.setText("   ==Datos del Profesor==");
				}
				{
					txtNomProf = new JTextField();
				}
				{
					lblNomProf = new JLabel();
					lblNomProf.setText("Nombre:");
				}
				{
					lblApellProf = new JLabel();
					lblApellProf.setText("Apellido:");
				}
				{
					lblNroSeccion = new JLabel();
					lblNroSeccion.setText(s.getNroSeccion());
				}
				{
					lblTAcProf = new JLabel();
					lblTAcProf.setText("Titulo Academico:");
				}
				{
					txtTAcProf = new JTextField();
				}
				{
					btAsigProf = new JButton();
					btAsigProf.setText("Asignar Profesor");
					btAsigProf.setBackground(new java.awt.Color(173,216,230));
					btAsigProf.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							System.out.println("btAsigProf.mouseClicked, event="+evt);
							//TODO add your code for btAsigProf.mouseClicked
							//Verifica si el profesor esta Asignado
							if(s.getProfesor()!=null)
							{
								if(s.getProfesor().getCedula().equals(txtCedProf.getText()))
								JOptionPane.showMessageDialog(null, "El Profesor ya se encuentra asignado");
								txtCedProf.setText("");
							}					
							else if(txtCedProf.getText().equals("") || txtNomProf.getText().equals("") || txtApeProf.getText().equals("") || txtTAcProf.getText().equals(""))
								{	
								JOptionPane.showMessageDialog(null, "Ingrese todos los datos");
								
				
								}
							
							 else
						 {
							Profesor prof = new Profesor(txtCedProf.getText(),txtNomProf.getText(), txtApeProf.getText(), txtTAcProf.getText());
							s.asigProfesor(prof);
							JOptionPane.showMessageDialog(null, "El profesor fue asignado exitosamente");
							txtCedProf.setText("");
							txtNomProf.setText("");
							txtApeProf.setText("");
							txtTAcProf.setText("");
							//btAsigProf.setVisible(false);
							
						 }	
					  }
					});

				}
				{
					txtApeProf = new JTextField();
				}
				{
					lblCedProf = new JLabel();
					lblCedProf.setText("Cedula:");
				}
				{
					txtCedProf = new JTextField();
				}
				jPanelProfLayout.setHorizontalGroup(jPanelProfLayout.createSequentialGroup()
					.addContainerGap(28, 28)
					.addGroup(jPanelProfLayout.createParallelGroup()
					    .addGroup(GroupLayout.Alignment.LEADING, jPanelProfLayout.createSequentialGroup()
					        .addGroup(jPanelProfLayout.createParallelGroup()
					            .addComponent(lblNomProf, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE)
					            .addGroup(GroupLayout.Alignment.LEADING, jPanelProfLayout.createSequentialGroup()
					                .addComponent(lblCedProf, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
					                .addGap(11))
					            .addComponent(lblApellProf, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE))
					        .addGap(45)
					        .addComponent(lblDatProf, GroupLayout.PREFERRED_SIZE, 235, GroupLayout.PREFERRED_SIZE)
					        .addGap(0, 87, Short.MAX_VALUE))
					    .addGroup(GroupLayout.Alignment.LEADING, jPanelProfLayout.createSequentialGroup()
					        .addComponent(lblTAcProf, GroupLayout.PREFERRED_SIZE, 124, GroupLayout.PREFERRED_SIZE)
					        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					        .addGroup(jPanelProfLayout.createParallelGroup()
					            .addGroup(GroupLayout.Alignment.LEADING, jPanelProfLayout.createSequentialGroup()
					                .addGroup(jPanelProfLayout.createParallelGroup()
					                    .addComponent(txtTAcProf, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE)
					                    .addComponent(txtApeProf, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE)
					                    .addComponent(txtNomProf, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE)
					                    .addComponent(txtCedProf, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE))
					                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					                .addComponent(btAsigProf, GroupLayout.PREFERRED_SIZE, 164, GroupLayout.PREFERRED_SIZE)
					                .addGap(0, 0, Short.MAX_VALUE))
					            .addGroup(GroupLayout.Alignment.LEADING, jPanelProfLayout.createSequentialGroup()
					                .addComponent(lblSecProf, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					                .addComponent(lblNroSeccion, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
					                .addGap(0, 148, Short.MAX_VALUE)))))
					.addContainerGap(35, 35));
				jPanelProfLayout.setVerticalGroup(jPanelProfLayout.createSequentialGroup()
					.addContainerGap(16, 16)
					.addGroup(jPanelProfLayout.createParallelGroup()
					    .addComponent(lblSecProf, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(lblNroSeccion, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
					.addGap(27)
					.addComponent(lblDatProf, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					.addGap(32)
					.addGroup(jPanelProfLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(lblCedProf, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(txtCedProf, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(jPanelProfLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(txtNomProf, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
					    .addComponent(lblNomProf, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					.addGroup(jPanelProfLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(txtApeProf, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
					    .addComponent(lblApellProf, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(jPanelProfLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(txtTAcProf, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
					    .addComponent(lblTAcProf, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(41)
					.addComponent(btAsigProf, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(62, Short.MAX_VALUE));
			}
			pack();
			setSize(506, 356);
			System.out.println(sec.getNroSeccion()); 
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
